
var Action = require("../apiaction");
var video_prefix="http://pteimg.b0.upaiyun.com/video/";
exports.pteAPI = function(router){

//删除课程

    router.get('/pte/act/course_delete',function(req,res){
        var act_id = req.param("act_id");
        var params = {course_id:act_id};
        Action.send(req, res,"dCourse",params);
    });
    //删除资讯
    router.get('/pte/act/info_delete',function(req,res){
        var act_id = req.param("act_id");
        var params = {info_id:act_id};
        Action.send(req, res,"dInfo",params);
    });
    //发布资讯
    router.post('/pte/act/addinfo',function(req,res){
        var category_id = req.param("category_id");
        var category_name = req.param("category_name");
        var cover = req.param("cover");
        var title = req.param("title");
        var content = req.param("content");
        var params = {category_id:category_id,category_name:category_name,content:content,cover:cover,title:title};
        Action.send(req, res,"cInfo",params);
    });
    //编辑资讯
    router.post('/pte/act/update_inform',function(req,res){
        var info_id = req.param("info_id");
        var category_id = req.param("category_id");
        var category_name = req.param("category_name");
        var content = req.param("content");
        var cover = req.param("cover");
        var title = req.param("title");

        var params = {info_id:info_id,category_id:category_id,category_name:category_name,content:content,cover:cover,title:title};
        Action.send(req, res,"uInfo",params);
    });
    //删除轮播图
    router.get('/pte/act/pic_delete',function(req,res){
        var pic_id = req.param("pic_id");
        var params = {pic_id:pic_id};
        Action.send(req, res,"dPicture",params);
    });
    //添加轮播图
    router.post('/pte/act/add_pic',function(req,res){
        var picture = req.param("picture");
        var params = {picture:picture};
        Action.send(req, res,"cPicture",params);
    });

    //同意--通过审核
    router.get('/pte/act/agree',function(req,res){
        var id=req.param("id");
        var imgurl=req.param("imgurl");
        var params = {id:id,imgurl:imgurl};
        Action.send(req, res,"getItPassed",params);
    });
    //拒绝--通过审核
    router.get('/pte/act/disagree',function(req,res){
        var id=req.param("id");
        var params = {id:id};
        Action.send(req, res,"getItRefused",params);
    });

//增加课程

    router.post('/pte/api/addcourse',function(req,res){
        var major_name = req.param("major_name");
        var major_id = req.param("major_id");
        var course_name = req.param("course_name");
        var cover = req.param("cover");
        var sequence = req.param("sequence");
        var teacher_name = req.param("teacher_name");
        var course_desc = req.param("course_desc");
        var params = {major_name:major_name,major_id:major_id,course_name:course_name,cover:cover,sequence:sequence,teacher_name:teacher_name,course_desc:course_desc};
        Action.send(req,res,'cCourse',params);

    });

    //添加分类
    router.post('/pte/api/add_fenlei',function(req,res){
        var cate_name = req.param("cate_name");
        var params = {cate_name:cate_name};
        Action.send(req,res,'cCategory',params);

    });
    //修改分类
    router.post('/pte/act/update_fenlei',function(req,res){
        var cate_name = req.param("cate_name");
        var category_id = req.param("category_id")
        var params = {cate_name:cate_name,category_id:category_id};
        Action.send(req,res,'uCategory',params);

    });
    //删除分类!!!
    router.get('/pte/api/del_fenlei',function(req,res){
        var category_id = req.param("category_id");
        var params = {category_id:category_id};
        Action.send(req, res,"dCategory",params);
    });


//�޸Ŀγ�
    router.post('/pte/act/editcourse',function(req,res) {
        var major_name = req.param("major_name");
        var major_id = req.param("major_id");
        var course_name = req.param("course_name");
        var cover = req.param("cover");
        var sequence = req.param("sequence");
        //var teacher_name = req.param("teacher_name");
        var course_desc = req.param("course_desc");
        var course_id = req.param("course_id");
        var params = {
            major_name: major_name,
            major_id: major_id,
            course_name: course_name,
            cover: cover,
            sequence: sequence,
            //teacher_name: teacher_name,
            course_desc: course_desc,
            course_id: course_id
        };
        Action.send(req, res, 'uCourse', params);

    })

    //添加课时测试
    router.post('/pte/api/addcourse-test',function(req,res){
        var content = req.param("content");
        var fullChar = req.param("fullChar");
        var image = req.param("image");
        var description = req.param("description");
        var context = req.param("context");
        var params = {content:content,fullChar:fullChar,image:image,description:description,context:context};
        Action.send(req,res,'cCitiao',params);
    });
//添加课程测试节点
    router.post('/pte/api/addtimecourse_test',function(req,res){
        var course_id = req.param('course_id');
        var lecture_id = req.param('lecture_id');
        var time = req.param('time');
        var question_id = req.param('question_id');
        var param = {course_id:course_id,lecture_id:lecture_id,time:time,question_id:question_id};
        console.log('参数哈哈哈',param);
        Action.send(req,res,'cJoint',param);
    })
//删除节点
    router.get('/pte/act/timecourse_test_delete', function (req, res) {
        var act_id = req.param("act_id");
        var params = {joint_id: act_id};
        console.log('删除节点',params);
        Action.send(req, res, "dJoint", params);
    });
 //修改节点
    router.post('/pte/api/timecourse_test_update',function(req,res){
        var course_id = req.param('course_id');
        var lecture_id = req.param('lecture_id');
        var joint_id = req.param('joint_id');
        var time = req.param('time');
        var question_id = req.param('question_id');
        var param = {course_id:course_id,lecture_id:lecture_id,joint_id:joint_id,time:time,question_id:question_id};
        console.log('修改节点参数',param);
        Action.send(req,res,'uJoint',param);
    });
    //添加词条
    router.post('/pte/api/addcitiao',function(req,res){
        var content = req.param("content");
        var fullChar = req.param("fullChar");
        var image = req.param("image");
        var description = req.param("description");
        var context = req.param("context");
        var params = {content:content,fullChar:fullChar,image:image,description:description,context:context};
        Action.send(req,res,'cCitiao',params);
    });


//删除词条
    router.get('/pte/act/citiao_delete', function (req, res) {
        var act_id = req.param("act_id");
        var params = {vocabulary_id: act_id};
        Action.send(req, res, "dCitiao", params);
    });
//修改词条

    router.post('/pte/api/citiao_update',function(req,res){
        var content = req.param("content");
        var fullChar = req.param("fullChar");
        var image = req.param("image");
        var description = req.param("description");
        var context = req.param("context");
        var vocabulary_id = req.param("vocabulary_id");
        var params = {vocabulary_id:vocabulary_id,content:content,fullChar:fullChar,image:image,description:description,context:context};
        Action.send(req, res,"uCitiao",params);
    });

    router.post('/pte/api/citiao_update',function(req,res){
        var content = req.param("content");
        var image = req.param("image");
        var description = req.param("description");
        var context = req.param("context");
        var vocabulary_id = req.param("vocabulary_id");
        var params = {vocabulary_id:vocabulary_id,content:content,image:image,description:description,context:context};
        Action.send(req, res,"uCitiao",params);
    });

    router.post('/pte/api/citiao_update', function (req, res) {
        var content = req.param("content");
        var image = req.param("image");
        var description = req.param("description");
        var context = req.param("context");
        var vocabulary_id = req.param("vocabulary_id");
        var params = {
            vocabulary_id: vocabulary_id,
            content: content,
            image: image,
            description: description,
            context: context
        };
        Action.send(req, res, "uCitiao", params);
    });
//删除评论
    router.get('/pte/act/citiao_pinglun_delete', function (req, res) {
        var act_id = req.param("act_id");
        var params = {vocComment_id: act_id};
        Action.send(req, res, "dCitiao_pinglun", params);
    });
//删除问题
    router.get('/pte/act/wenda_delete', function (req, res) {
        var act_id = req.param("act_id");
        var params = {trouble_id: act_id};
        Action.send(req, res, "dTrouble", params);
    });
//专家回答
    router.post('/pte/api/addAnswer',function(req,res){



        var content = req.param("content");
        var trouble_id = req.param("trouble_id");
        var params = {content:content,trouble_id:trouble_id};
        Action.send(req,res,'cAnswer',params);

    });
    router.post('/pte/api/addAnswer',function(req,res){
        var content = req.param("content");
        var trouble_id = req.param("trouble_id");
        var params = {content:content,trouble_id:trouble_id};
        Action.send(req,res,'cAnswer',params);
    });
    router.post('/pte/api/addAnswer', function (req, res) {
        var content = req.param("content");
        var trouble_id = req.param("trouble_id");
        var params = {content: content, trouble_id: trouble_id};
        Action.send(req, res, 'cAnswer', params);
    });
    //删除问题
    router.get('/pte/act/answer_delete',function(req,res){
        var act_id = req.param("act_id");
        var params = {answer_id:act_id};
        Action.send(req, res,"dAnswer",params);
    });
//���ӿ

    router.post('/pte/act/addlecture',function(req,res) {
        var course_id = req.param("course_id");
        var course_name = req.param("course_name");
        var cover = req.param("cover");
        var sequence = req.param("sequence");
        var lecture_name = req.param("lecture_name");
        var video_url = req.param("video_url");
        video_url=video_prefix+video_url;
        var description=req.param("description");
        var teacher_id=req.param("teacher_id");
        var params = {
            description: description,
            teacher_id: teacher_id,
            course_id: course_id,
            course_name: course_name,
            last:req.param("last"),
            cover: cover,
            sequence: sequence,
            lecture_name: lecture_name,
            video_url: video_url
        };
        Action.send(req, res, 'cLecture', params);


    })


    router.get('/pte/act/lecture_delete', function (req, res) {
        var act_id = req.param("act_id");
        var params = {lecture_id: act_id};
        Action.send(req, res, "dLecture", params);
    });

//删除评论
    router.get('/pte/act/citiao_delete', function (req, res) {
        var act_id = req.param("act_id");
        var params = {vocabulary_id: act_id};
        Action.send(req, res, "dCitiao", params);
    });


    router.post('/pte/act/editlecture', function (req, res) {
        var course_id = req.param("course_id");
        var sequence = req.param("sequence");
        var course_name = req.param("course_name");
        var cover = req.param("cover");
        var del_flag = req.param("del_flag");
        var lecture_name = req.param("lecture_name");
        var video_url = req.param("video_url");
        video_url=video_prefix+video_url;
        var lecture_id = req.param("lecture_id");
        var description=req.param("description");
        var teacher_id=req.param("teacher_id");
        var params = {
            course_id: course_id,
            teacher_id:teacher_id,
            description:description,
            sequence: sequence,
            course_name: course_name,
            cover: cover,
            del_flag: del_flag,
            last:req.param("last"),
            lecture_name: lecture_name,
            video_url: video_url,
            lecture_id: lecture_id
        };
        Action.send(req, res, "uLecture", params);
    });


    router.post('/pte/act/addquestion',function(req,res){
        var course_id = req.param("course_id");
        var course_name = req.param("course_name");
        var type = req.param("type");
        var title = req.param("title");
        var options = req.param("options");
        var params = {course_id:course_id,course_name:course_name,type:type,title:title,options:options};
        Action.send(req, res,"cQuestion",params);
    });
    //�޸Ŀγ���Ŀ
    router.post('/pte/act/editquestion',function(req,res){
        var course_id = req.param("course_id");
        var question_id = req.param("question_id");
        var course_name = req.param("course_name");
        var type = req.param("type");
        var title = req.param("title");
        var options = req.param("options");
        var params = {course_id:course_id,question_id:question_id,course_name:course_name,type:type,title:title,options:options};
        Action.send(req, res,"uQuestion",params);
    });
    //ɾ����Ŀ
    router.get('/pte/act/question_delete',function(req,res){
        var act_id = req.param("act_id");
        var params = {question_id:act_id};
        Action.send(req, res,"dQuestion",params);
    });
    //添加案例
    router.post('/pte/act/add_case',function(req,res){
        var lecture_ids = req.param("lecture_ids");
        var title = req.param("title");
        var content = req.param("content");
        var param = {title:title,lecture_ids:lecture_ids,content:content};
        Action.send(req, res,"cCase",param);
    });

    //编辑案例
    router.post('/pte/act/update_case',function(req,res){
        var example_id = req.param("example_id");
        var title = req.param("title");
        var lecture_ids = req.param("lecture_ids");
        var content = req.param("content");
        var params = {example_id:example_id,lecture_ids:lecture_ids,title:title,content:content};
        Action.send(req, res,"uCase",params);
    });
    //课程下的课时
    router.post('/pte/api/getCourseLecture',function(req,res){
        var course_id= req.param("course_id");
        var param = {course_id:course_id};
        Action.send(req, res,"rLectureS",param);
    });
    //删除案例
    router.get('/pte/act/case_delete',function(req,res){
        var act_id = req.param("act_id");
        var params = {example_id:act_id};
        Action.send(req, res,"dCase",params);
    });

    //添加教师
    router.post('/pte/act/add_teacher',function(req,res){
        var teacher_name = req.param("teacher_name");
        var avatar = req.param("avatar");
        var teacher_desc = req.param("teacher_desc");
        var param = {teacher_name:teacher_name,avatar:avatar,teacher_desc:teacher_desc};
        Action.send(req, res,"cTeacher",param);
    });
    //删除教师
    router.get('/pte/act/teacher_delete',function(req,res){
        var act_id = req.param("act_id");
        var params = {teacher_id:act_id};
        Action.send(req, res,"dTeacher",params);
    });
    //编辑老师
    router.post('/pte/act/update_teacher',function(req,res){
        var teacher_id= req.param("teacher_id");
        var teacher_name = req.param("teacher_name");
        var avatar = req.param("avatar");
        var teacher_desc = req.param("teacher_desc");
        var param = {teacher_id:teacher_id, teacher_name:teacher_name,avatar :avatar,teacher_desc:teacher_desc};
        Action.send(req, res,"uTeacher",param);
    });


    //编辑证书
    router.post('/pte/act/uCertificate',function(req,res){
        var certificate_id= req.param("id");
        var price = req.param("price");
        var title = req.param("title");
        var content = req.param("content");
        var param = {certificate_id:certificate_id, price:price,title :title,content:content};
        Action.send(req, res,"uCertificate",param);
    });


    //��ӿγ���Ŀ

    router.post('/pte/act/addquestion', function (req, res) {
        var course_id = req.param("course_id");
        var course_name = req.param("course_name");
        var type = req.param("type");
        var title = req.param("title");
        var options = req.param("options");
        var params = {course_id: course_id, course_name: course_name, type: type, title: title, options: options};
        Action.send(req, res, "cQuestion", params);
    });
    //�޸Ŀγ���Ŀ
    router.post('/pte/act/editquestion', function (req, res) {
        var course_id = req.param("course_id");
        var question_id = req.param("question_id");
        var course_name = req.param("course_name");
        var type = req.param("type");
        var title = req.param("title");
        var options = req.param("options");
        var params = {
            course_id: course_id,
            question_id: question_id,
            course_name: course_name,
            type: type,
            title: title,
            options: options
        };
        Action.send(req, res, "uQuestion", params);
    });
    //ɾ����Ŀ
    router.get('/pte/act/question_delete', function (req, res) {
        var act_id = req.param("act_id");
        var params = {question_id: act_id};
        Action.send(req, res, "dQuestion", params);
    });
    //封号
    router.get('/pte/act/user_freeze', function (req, res) {
        var act_id = req.param("act_id");
        var params = {user_id: act_id};
        Action.send(req, res, "freeze", params);
    })
    //解封
    router.get('/pte/act/user_unfreeze', function (req, res) {
        var act_id = req.param("act_id");
        var params = {user_id: act_id};
        Action.send(req, res, "unfreeze", params);
    });
    //专业
    router.post('/pte/api/major',function(req,res){
        var param={}
        if(req.param("keyword"))
            param.keyword=req.param("keyword");
        Action.send(req, res, "major", param,function(res,data){
            res.status(200).send(data);
        })
    })

    router.post("/pte/api/addMajor",function(req,res){
        var major_name = req.param("major_name");
        var major_desc = req.param("major_desc");
        var params = {major_name: major_name,major_desc:major_desc};
        Action.send(req, res, "addMajor", params);
    });

    router.post("/pte/api/delMajor",function(req,res){
        var major_id=req.param("major_id");
        Action.send(req, res, "delMajor", {major_id:major_id});
    })

    router.post("/pte/api/updateMajor",function(req,res){
        var major_name = req.param("major_name");
        var major_desc = req.param("major_desc");
        var major_id = req.param("major_id");

        var params = {major_name: major_name,major_desc:major_desc,major_id:major_id};
        Action.send(req, res, "updateMajor", params);
    })
    router.post("/api/genInvite",function(req,res){
        var genCount = req.param("num");
        var params = {genCount: genCount};
        Action.send(req, res, "genInvite", params);
    });

    //邀请码列表
    router.post('/pte/api/invite',function(req,res){
        var param={}
        if(req.param("keyword"))
            param.keyword=req.param("keyword");
        Action.send(req, res, "invite", param,function(res,data){
            res.status(200).send(data);
        })
    })
}
